package com.liao.content.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liao.base.model.PageParams;
import com.liao.base.model.PageResult;
import com.liao.content.mapper.MovieBaseMapper;
import com.liao.content.model.dto.QueryCourseParamsDto;
import com.liao.content.model.po.CourseBase;
import com.liao.content.model.po.MovieBase;
import com.liao.content.service.MovieBaseService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 电影基本表 服务实现类
 * </p>
 *
 * @author liao
 */
@Slf4j
@Service
public class MovieBaseServiceImpl extends ServiceImpl<MovieBaseMapper, MovieBase> implements MovieBaseService {


    @Autowired
    MovieBaseMapper movieBaseMapper;

    @Override
    public PageResult<MovieBase> queryMovieBaseList(PageParams params) {
        LambdaQueryWrapper<MovieBase> queryWrapper = new LambdaQueryWrapper<>();


        //分页参数
        Page<MovieBase> page = new Page<>(params.getPageNo(), params.getPageSize());


        Page<MovieBase> pageResult = movieBaseMapper.selectPage(page,queryWrapper);

        //数据
        List<MovieBase> items = pageResult.getRecords();
        //总记录数
        long total = pageResult.getTotal();


        //准备返回数据 List<T> items, long counts, long page, long pageSize
        PageResult<MovieBase> movieBasePageResult = new PageResult<>(items, total, params.getPageNo(), params.getPageSize());

        return movieBasePageResult;
    }
}
